BSTNode rotateWithLeftChild(BSTNode k2) { BSTNode k1 = k2.left; k2.left = k1.right; k1.right = k2; return k1; } BSTNode rotateWithRightChild(BSTNode k1) { BSTNode k2 = k1.right; k1.right = k2.left; k2.left = k1; return k2; } BSTNode doubleRotateWithLeftChild(BSTNode k3) { k3.left = rotateWithRightChild( k3.left ); return rotateWithLeftChild( k3 ); } BSTNode doubleRotateWithRightChild(BSTNode k1) { k1.right = rotateWithLeftChild( k1.right); return rotateWithRightChild( k1 ); }